//
// Created by liuyang on 2025/5/15.
//

#ifndef COMPUTERORDERSYSTEM_DBMAPPER_H
#define COMPUTERORDERSYSTEM_DBMAPPER_H
#include "vector"
#include "Person.h"
#include "Student.h"
#include "Manager.h"
#include "Teacher.h"
#include "../Utils/Constant.h"
#include "fstream"
#include "ostream"
#include "map"
#include "ComputerRoom.h"
#include "Order.h"
#include "string"
#include "sstream"

using namespace std;


class DBMapper {
public:
    inline static vector<Student> studentData;
    inline static vector<Teacher> teacherData;
    inline static vector<Manager> managerData;
    inline static map<int,ComputerRoom> computerRoomData;
    inline static vector<Order> orderData;


    static vector<Student> selectAllStudents();

    static vector<Teacher> selectAllTeachers();

    static vector<Order> selectAllOrders();

    static void initDB();

    static Student* selectStudent(Student& s);

    static Teacher* selectTeacher(Teacher& t);

    static Manager* selectManager(Manager& t);

    static void initStudent();

    static void initTeacher();

    static map<int,ComputerRoom> selectAllComputers();

    static void initComputerRoom();

    static bool isExistRoom(int id);

    static void increaseRoomUsage(int id);

    static void insertOrder(Order& order);

    static void flushComputerData();

    static void initOrder();

    static void flushOrderData();

    static Student deserialize(string str);

    static vector<Order> showOrderByStudentId(int id);

    static bool updateOrder(int id, int state);


    static Order* selectOrderById(int orderId);
};


#endif //COMPUTERORDERSYSTEM_DBMAPPER_H
